package com.mutual.assistance.task.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author chenyuxin
 * @version 1.0
 * @description Redisson配置
 * @date 2023/5/3 15:26
 */
@Configuration
public class RedissonConfig {

    @Value("${spring.redis.host}")
    private String redisAddress;

    @Value("${spring.redis.password}")
    private String password;

    @Bean
    public RedissonClient redissonClient(){
        Config config = new Config();
        String redisAddressUser = "redis://" + redisAddress + ":6379";
        config.useSingleServer().setAddress(redisAddressUser)
                .setPassword(password);
        return Redisson.create(config);
    }
}

